Skip to content

[#244][#245] Zap v2 frontend: multi-token lib + UI#436

Merged
realproject7 merged 2 commits intomainfrom
task/434-zap-v2-frontend
Mar 22, 2026
Merged

[#244][#245] Zap v2 frontend: multi-token lib + UI#436
realproject7 merged 2 commits intomainfrom
task/434-zap-v2-frontend

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

Test plan

  • Verify lint and typecheck pass
  • Verify ETH/USDC/HUNT/PLOT toggle renders on buy tab
  • Verify PLOT mode works (existing behavior)
  • Test ETH mode quote estimation
  • Test USDC mode approval + zap flow
  • Verify sell tab unchanged
  • Verify trade indexing fires for all modes
  • Verify selector hidden when ZAP_PLOTLINK is zero address

Fixes realproject7/agent-os#244, Fixes realproject7/agent-os#245

🤖 Generated with Claude Code

#245: Rewrite lib/zap.ts for ZapPlotLinkV2 multi-token ABI:
- New ABI: mint(fromToken, storylineToken, ...), mintReverse(...),
  estimateMint(...), estimateMintReverse(...)
- getZapQuote calls contract estimates via simulateContract (non-view)
- buildZapMintTx handles ETH (payable) vs ERC-20 (approval) paths
- Removed V4 Quoter calls — contract handles full path internally
- 3% slippage buffer on bonding curve execution

Update constants.ts:
- ZAP_PLOTLINK mainnet: 0xEF6a8640c836b16Eb8cCD8016Ead4C8517aC3033
- Added USDC, HUNT, ETH_ADDRESS constants
- Added SUPPORTED_ZAP_TOKENS list for frontend selector

#244: Multi-token selector on TradingWidget buy tab:
- 4 options: ETH, USDC, HUNT, PLOT (default: ETH)
- ETH: payable zap tx, no approval, balance via useBalance
- USDC/HUNT: approve to ZAP_PLOTLINK → zap tx, balance via balanceOf
- PLOT: existing direct MCV2_Bond.mint flow unchanged
- USDC handled as 6 decimals for balance display
- Sell tab: unchanged
- Trade indexing fires for all modes
- isZapAvailable hides selector when zap address is zero

Fixes #244, Fixes #245

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The mainnet path looks directionally right, but this PR regresses the existing Sepolia/testnet frontend by wiring the new V2 ABI against the old V1 testnet zap address and by exposing mainnet USDC/HUNT addresses on all chains.

Findings

  • [high] lib/zap.ts now always uses the V2 ABI, but ZAP_PLOTLINK still points to the old Sepolia V1 contract on testnet. On Base Sepolia, getZapQuote() / buildZapMintTx() will call estimateMint / mint(fromToken,...) against 0xC7C47D..., which is the previous ETH-only zap and does not match this ABI. That breaks the existing testnet zap flow instead of preserving it.
    • File: lib/contracts/constants.ts:37
    • Suggestion: either gate the V2 frontend to mainnet only (hide zap modes on testnet), or deploy/update a matching Sepolia V2 zap address before switching the frontend ABI globally.
  • [high] USDC, HUNT, and SUPPORTED_ZAP_TOKENS are exported unconditionally with Base mainnet token addresses. Because the widget only checks whether ZAP_PLOTLINK is nonzero, Base Sepolia users will still see USDC/HUNT options and the app will check balances / approvals against mainnet token contracts on the wrong chain.
    • File: lib/contracts/constants.ts:55
    • Suggestion: make the supported zap token list chain-aware, or suppress non-PLOT zap options on testnet until Sepolia addresses and a matching zap deployment exist.

Decision

Requesting changes because this PR introduces a cross-network frontend regression even if the mainnet integration itself is correct.

…2 ABI

Set testnet ZAP_PLOTLINK to zero address until a V2 contract is
deployed to Base Sepolia. This prevents the V2 frontend from calling
V2 ABI functions against the old V1 Sepolia deployment.

The isZapAvailable check in TradingWidget already hides the token
selector when ZAP_PLOTLINK is zero, so testnet users fall back to
direct PLOT mode only.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Review — APPROVED

No blockers. Core logic is solid across all three files.

Verified correct

  • ABI signatures match ZapPlotLinkV2 contract ✓
  • simulateContract used for non-view estimates ✓
  • ETH: payable with msg.value, no approval ✓
  • USDC/HUNT: allowance check → approve → mint (two-step) ✓
  • USDC 6 decimals handled correctly ✓
  • 3% slippage buffer applied correctly ✓
  • PLOT direct path unchanged ✓
  • Sell tab unchanged ✓
  • V4 Quoter calls fully removed ✓
  • Trade indexing fires for all modes ✓
  • isZapAvailable hides non-PLOT options when zap is zero ✓
  • No dead code from v1 ✓
  • Constants match spec ✓

WARN (non-blocking)

  1. Button label when zap unavailable: When isZapAvailable is false, payToken defaults to "ETH" but isPlotMode is true — button says "Buy with ETH" instead of "Buy with PLOT". Trade executes correctly, just label is misleading.

  2. Stale useCallback dep: refetchBalance captures isEthMode but doesn't list it in dependencies. Could cause stale refetch when switching pay tokens.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The Sepolia gating fix resolves the cross-network regression, and the updated multi-token frontend wiring is consistent with the deployed V2 contract. CI is green.

Findings

  • No blocking findings.

Decision

Approving because the mainnet multi-token zap flow is wired correctly, testnet is safely gated off, and the build is passing.

@realproject7 realproject7 merged commit bf4dd56 into main Mar 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants